package com.amigo.online.provider.common.service.impl;


import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.amigo.online.common.base.service.BaseService;
import com.amigo.online.common.param.result.GlobalConfigInfo;
import com.amigo.online.provider.common.mapper.GlobalConfigMapper;
import com.amigo.online.provider.common.model.entity.GlobalConfig;
import com.amigo.online.provider.common.service.GlobalConfigService;
import com.amigo.online.provider.common.util.ConvertUtil;

@Service
@Transactional(rollbackFor = Exception.class)
public class GlobalConfigServiceImpl extends BaseService<GlobalConfig> implements GlobalConfigService {

    @Resource
    private GlobalConfigMapper globalConfigMapper;

    @Override
    public List<GlobalConfigInfo> getGlobalConfigList() {

        List<GlobalConfig> gc_list = globalConfigMapper.getConfigList();
        if (gc_list == null) {
            return null;
        }
        List<GlobalConfigInfo> info_list = new ArrayList<GlobalConfigInfo>();
        if (gc_list.size() <= 0) {
            return info_list;
        }
        for (GlobalConfig gc : gc_list) {
            GlobalConfigInfo info = ConvertUtil.GlobalConfigToGlobalConfigInfo(gc);
            info_list.add(info);
        }
        return info_list;
    }

    @Override
    public GlobalConfigInfo getGlobalMd5() {
        //  Auto-generated method stub
        GlobalConfig gc = globalConfigMapper.getMd5();
        if (gc == null) {
            return null;
        }
        GlobalConfigInfo info = ConvertUtil.GlobalConfigToGlobalConfigInfo(gc);
        return info;
    }


}
